package com.forte.cartdao;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

import com.forte.shoppingcustomerdao.ShoppingCustomer;


@Entity(name="cart")
public class Cart implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Id
	@Column
	private int cartId;
	
	@Column
	private int userId;
	
	@Column
	private String cookieId;
	
	@Column
	private Date createdDate;
	
	@OneToOne(cascade = CascadeType.ALL)
	@JoinColumn(name="userId", insertable=false, updatable=false)
	private ShoppingCustomer customer;
	
	@OneToMany(fetch = FetchType.EAGER, mappedBy="cart")
	private Set<CartProduct> cartProduct = new HashSet<CartProduct>();	

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public Date getCreatedDate() {
		return createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}
	
	public ShoppingCustomer getCustomer(){
		return customer;
	}
	
	public Set<CartProduct> getCartProduct(){
		return cartProduct;
	}

	public String getCookie() {
		return cookieId;
	}

	public void setCookie(String cookieId) {
		this.cookieId = cookieId;
	}

	public int getCartId() {
		return cartId;
	}

	public void setCartId(int cartId) {
		this.cartId = cartId;
	}

}
